#include "lib/svg.cpp"
#include "lib/web.cpp"
#include <ctime>
#include <cmath>

string _2str(double d) {
	stringstream ss;
	ss << d;
	return ss.str();
}

int main() {
	time_t now = time(0);
	tm * ltm = localtime(&now);
	SVG svg;
	double PI = 3.141592654;

	circle c;
	c.cx = "100";
	c.cy = "100";
	c.r = "100";
	c.fill = "#CCFFCC";
	c.stroke_width = "0";

	line h;
	h.x1 = "100";
	h.y1 = "100";
	h.x2 = _2str(100+60*sin(2*PI*(ltm->tm_hour%12+(ltm->tm_min/60.))/12));
	h.y2 = _2str(100-60*cos(2*PI*(ltm->tm_hour%12+(ltm->tm_min/60.))/12));
	h.stroke = "#333333";
	h.stroke_width = "10";

	line m;
	m.x1 = "100";
	m.y1 = "100";
	m.x2 = _2str(100+80*sin(2*PI*(ltm->tm_min%60)/60));
	m.y2 = _2str(100-80*cos(2*PI*(ltm->tm_min%60)/60));
	m.stroke = "#336633";
	m.stroke_width = "7";

	line s;
	s.x1 = "100";
	s.y1 = "100";
	s.x2 = _2str(100+95*sin(2*PI*(ltm->tm_sec%60)/60));
	s.y2 = _2str(100-95*cos(2*PI*(ltm->tm_sec%60)/60));
	s.stroke = "#339933";
	s.stroke_width = "5";

	svg += c;
	svg += s;
	svg += m;
	svg += h;
	cout << svg;

	data["app_request"] = "1000 example_8_clock";

	cerr << "时间: "<< ltm->tm_hour << ":";
	cerr << ltm->tm_min << ":";
	cerr << ltm->tm_sec << endl;
}